/*
  Copyright © 2010  Vinícius dos Santos Oliveira
  Copyright © 2010  Felipe Carlos Lima dos Santos

      This file is part of Touché.

      Touché is free software: you can redistribute it and/or modify
      it under the terms of the GNU Lesser General Public License as published
      by the Free Software Foundation, either version 3 of the License, or
      (at your option) any later version.

      This program is distributed in the hope that it will be useful,
      but WITHOUT ANY WARRANTY; without even the implied warranty of
      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      GNU Lesser General Public License for more details.

      You should have received a copy of the GNU Lesser General Public License
      along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */

#ifndef PUSHBUTTONITEM_H
#define PUSHBUTTONITEM_H

#include <QGraphicsObject>
#include <QSvgRenderer>

class PushButtonItem: public QGraphicsObject
{
    Q_OBJECT

    QSvgRenderer image;
    bool checkable;
    bool checked;
    bool m_hasBg;
    bool mustHighlight;
    QRectF pressedAt;

protected:
    virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
    virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
    virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);

public:
    PushButtonItem(const QString &fileName, QGraphicsItem *parentItem = 0);

    bool isCheckable() const;
    void setCheckable(bool);
    bool isChecked() const;
    void setHasBg(bool);
    bool hasBg() const;

    QRectF boundingRect() const;
    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);

public slots:
    void setChecked(bool);
    void toggle();

signals:
    void clicked(PushButtonItem * = NULL);
    void pressed();
    void released();
    void toggled(bool checked);
};

#endif // PUSHBUTTONITEM_H
